package com.xiaochun.jiankangapp.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.xiaochun.jiankangapp.model.Response
import com.xiaochun.jiankangapp.network.Request
import kotlinx.coroutines.launch

class InputInfoViewModel : ViewModel() {
    fun save(callback: (Response<Any>) -> Unit) {
        viewModelScope.launch {
            val r = Request.postSuspend<Any>(
                "api/material/add",
                mapOf(
                    "sex" to if (gender == 1) "men" else "women",
                    "birth" to year.toString() + "年" + month.toString() + "月" + day.toString() + "日",
                    "height" to height,
                    "weight" to weight,
                    "name" to name,
                    "mobile" to phone
                )
            )
            callback.invoke(r)
        }
    }

    var gender: Int = 1
    var height = 0
    var weight = 0
    var year: Int = 0
    var month = 0
    var day = 0
    var name = ""
    var phone = ""
}